<?php

/*
 * Object/InstructionPaieGroup.php
 */

namespace RHX\Model\Object;

use Zend\Db\Adapter\Adapter;

class InstructionPaieGroup {

    public $id;
    public $libelle;
    public $description;
    public $periode_id;
    public $site_id;
    protected $adapter;

    /**
     * Constructeur
     * 
     * @param \Zend\Db\Adapter\Adapter $adapter
     * @param array $data
     */
    public function __construct(Adapter $adapter, $data = array()) {
	$this->adapter = $adapter;
	$this->exchangeArray($data);
    }

    /**
     * Remplissage des données
     * 
     * @param array $data
     */
    public function exchangeArray($data) {
	$this->id		 = isset($data['id']) ? (int) $data['id'] : null;
	$this->libelle		 = isset($data['libelle']) ? $data['libelle'] : null;
	$this->description	 = isset($data['description']) ? $data['description'] : null;
	$this->periode_id	 = isset($data['periode_id']) ? (int) $data['periode_id'] : null;
	$this->site_id		 = isset($data['site_id']) ? (int) $data['site_id'] : null;
    }
    
    /**
     * Période
     * 
     * @return Periode
     */
    public function getPeriode(){
	try{
	    $tablePeriode = new \RHX\Model\Table\PeriodeTable($this->adapter);
	    return $tablePeriode->get($this->periode_id);
	} catch (Exception $ex) {
	    return null;
	}
    }
    
    /**
     * Site
     * 
     * @return Site
     */
    public function getSite(){
	try{
	    $tableSite = new \RHX\Model\Table\SiteTable($this->adapter);
	    return $tableSite->get($this->site_id);
	} catch (Exception $ex) {
	    return null;
	}
    }

}
